<div class="form wide">

<?php $form=$this->beginWidget('FActiveForm', array(
	'id'=>'user-profile-form',
	'enableAjaxValidation'=>false,
)); ?>

	<!--<p class="note">Fields with <span class="required">*</span> are required.</p>-->
    
    <?php if (! $model->IsNewRecord) echo $form->hiddenField($model, "id") ; ?>
        <?php echo $form->hiddenField($model,'user_id'); ?>
	<!--<div class="row">
		<?php echo $form->labelEx($model,'user_id'); ?>
		<?php echo $form->textField($model,'user_id'); ?>
		<?php echo $form->error($model,'user_id'); ?>
	</div>-->
    <div class="row">
        <?php echo $form->labelEx($model,'avatar'); ?>
        <?php //echo $form->textField($model,'avatar',array('size'=>60,'maxlength'=>200)); ?>
        <?php  
            $this->widget('ext.EAjaxUpload.EAjaxUpload',array(
                'id'=>'image',
                'fileName'=>$model->avatar,
                'location'=>Yii::app()->params['ProfileFolder'],
                'maxFile'=>1,
                'fieldName'=>"UserProfile[avatar]",
                'config'=>array(
                    'action'=>Yii::app()->createUrl('//site/ajaxUpload'),
                    'allowedExtensions'=>Yii::app()->params['AllowImageType'],//array("jpg","jpeg","gif","exe","mov" and etc...
                    'sizeLimit'=>Yii::app()->params['MaxImageSize'],// maximum file size in bytes
                    'minSizeLimit'=>0,// minimum file size in bytes
                    'onComplete'=>"js:function(id, fileName, responseJSON){                     
                        var result=eval(responseJSON);
                        $('.qq-upload-button').hide();
                        $('.qq-upload-list li').append('<img style=\"width:100px\" id=\"'+result.filename+'\" class=\"image\" src=\"uploads/tmpImages/'+result.filename+'\"  />');                                         
                        $('#image').append('<input type=\"hidden\" class=\"new\" name=\"UserProfile[avatar]\" value=\"'+result.filename+'\" />');               
                    }",                    
                    )
                )); 
        ?>
        <?php //echo $form->error($model,'avatar'); ?>
    </div>
    <p class="hint">Bấm nút <span class="required">X</span>(nếu có) để đổi avatar khác.<br/>
    Cho phép tối đa 1024 kb(1M) các file JPG, GIF, hoặc PNG.<br/>
    Hình upload của bạn sẽ tự động thu nhỏ.
    </p>
	<div class="row">
		<?php echo $form->labelEx($model,'full_name'); ?>
		<?php echo $form->textField($model,'full_name',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'full_name'); ?>
	</div>

    
    <div class="row">
        <?php echo $form->labelEx($model,'phone'); ?>
        <?php echo $form->textField($model,'phone',array('size'=>60,'maxlength'=>100)); ?>
        <?php echo $form->error($model,'phone'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'yahoo_id'); ?>
        <?php echo $form->textField($model,'yahoo_id',array('size'=>60,'maxlength'=>100)); ?>
        <?php echo $form->error($model,'yahoo_id'); ?>
    </div>
    
    
	<div class="row">
		<?php echo $form->labelEx($model,'address'); ?>
		<?php echo $form->textField($model,'address',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'address'); ?>
	</div>
    
	<div class="row">
		<?php echo $form->labelEx($model,'bio'); ?>
		<?php echo $form->textArea($model,'bio',array('cols'=>35,'rows'=>6,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'bio'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'website'); ?>
		<?php echo $form->textField($model,'website',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'website'); ?>
	</div>

	<!--<div class="row">
		<?php echo $form->labelEx($model,'create_time'); ?>
		<?php echo $form->textField($model,'create_time'); ?>
		<?php echo $form->error($model,'create_time'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'update_time'); ?>
		<?php echo $form->textField($model,'update_time'); ?>
		<?php echo $form->error($model,'update_time'); ?>
	</div>-->

	 <div class="row buttons">
    <div class="button left-fragment">
        <div class="right-fragment">
        <?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
        <?php echo CHtml::submitButton('Lưu'); ?>
        </div>
    </div> 
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<?php 
$style="
ul.qq-upload-list {clear: both;list-style: none outside none;margin: 15px 0 15px 150px;padding: 0;}
";
$btn=".qq-upload-button{display:none;}";
if($model->avatar!='')
    cs()->registerCss('#btn',$btn);
cs()->registerCss('#upload_field',$style);
?>